
Partial Class Modules_Questionnaires_Controls_cfgDate
    Inherits System.Web.UI.UserControl
    Implements DotNetPM.Business.Questionnaire.UserControls.IConfigUC

    Private _AnswerType As Integer

    Public Property AnswerType() As Integer Implements DotNetPM.Business.Questionnaire.UserControls.IConfigUC.AnswerType
        Get
            Return _AnswerType
        End Get
        Set(ByVal value As Integer)
            _AnswerType = value
        End Set
    End Property

    Public Property Config() As String Implements DotNetPM.Business.Questionnaire.UserControls.IConfigUC.Config
        Get
            Dim build As New StringBuilder
            build.Append(_AnswerType)
            build.Append("||" & rRequired.SelectedIndex)
            build.Append("||" & ddlDateType.SelectedIndex)
            build.Append("||" & IIf(calMin.SelectedDate.Year = 1, String.Empty, calMin.SelectedDate))
            build.Append("||" & IIf(calMax.SelectedDate.Year = 1, String.Empty, calMax.SelectedDate))
            Return build.ToString
        End Get
        Set(ByVal value As String)
            Dim val As String() = Split(value, "||")
            _AnswerType = val(0)
            Integer.TryParse(val(1), rRequired.SelectedIndex)
            Integer.TryParse(val(2), ddlDateType.SelectedIndex)
            If Not String.IsNullOrEmpty(val(3)) Then calMin.SelectedDate = val(3)
            If Not String.IsNullOrEmpty(val(4)) Then calMax.SelectedDate = val(4)
        End Set
    End Property

    Public Sub Reset() Implements DotNetPM.Business.Questionnaire.UserControls.IConfigUC.Reset
        ' Clear values
        calMin.SelectedDate = "1573-01-01"
        calMax.SelectedDate = "9999-12-31"
        rRequired.SelectedIndex = 1
    End Sub
End Class
